package org.shopen.puremvc.view
{
	import org.puremvc.as3.interfaces.INotification;
	import org.puremvc.as3.patterns.mediator.Mediator;
	import org.shopen.puremvc.ApplicationConstants;
	import org.shopen.puremvc.view.components.welcome.WelcomeWindow;
	import org.shopen.puremvc.view.components.welcome.WelcomeWindowEvent;

	public class WelcomeWindowMediator extends Mediator
	{
		public static const NAME : String = "WelcomeWindowMediator";
		
		protected function get welcomeWindow() : WelcomeWindow
		{
			var result : WelcomeWindow = viewComponent as WelcomeWindow;
			return result;
		}
		
		public function WelcomeWindowMediator(viewComponent:Object=null)
		{
			super(WelcomeWindowMediator.NAME, viewComponent);
		}
		
		override public function onRegister():void
		{
			addListeners();
		}
				
		override public function getMediatorName():String
		{
			return WelcomeWindowMediator.NAME;
		}
		
		override public function listNotificationInterests():Array
		{
			return [];
		}
		
		override public function handleNotification(notification:INotification):void
		{
			
		}
		
		private function addListeners() : void
		{
			welcomeWindow.addEventListener(WelcomeWindowEvent.ABOUT_REQUEST, handleAboutRequest);
			welcomeWindow.addEventListener(WelcomeWindowEvent.HELP_REQUEST, handleHelpRequest);
			welcomeWindow.addEventListener(WelcomeWindowEvent.NEWFILE_REQUEST, handleNewfileRequest);
			welcomeWindow.addEventListener(WelcomeWindowEvent.OPENFILE_REQUEST, handleOpenfileRequest);
		}
		
		private function handleAboutRequest(event : WelcomeWindowEvent) : void
		{
			sendNotification(ApplicationConstants.ABOUT_REQUEST);
		}
		
		private function handleHelpRequest(event : WelcomeWindowEvent) : void
		{
			sendNotification(ApplicationConstants.HELP_REQUEST);
		}
		private function handleNewfileRequest(event : WelcomeWindowEvent) : void
		{
			sendNotification(ApplicationConstants.CREATING_REQUEST);
		}
		private function handleOpenfileRequest(event : WelcomeWindowEvent) : void
		{
			sendNotification(ApplicationConstants.OPENING_REQUEST);
		}
		
	}
}